﻿<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>打包工具</title>
<link type="text/css" href="../css/themes/green/jquery.ui.all.css" rel="stylesheet" />
	<script type="text/javascript" src="../js/jquery-1.4.2.js"></script>
	<script type="text/javascript" src="../js/external/jquery.bgiframe-2.1.1.js"></script>
	<script type="text/javascript" src="../js/jquery-ui/jquery.ui.core.js"></script>
	<script type="text/javascript" src="../js/jquery-ui/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="../js/jquery-ui/jquery.ui.tabs.js"></script>
	<script type="text/javascript" src="../js/jquery-ui/jquery.ui.mouse.js"></script>
	<script type="text/javascript" src="../js/jquery-ui/jquery.ui.draggable.js"></script>
	<script type="text/javascript" src="../js/jquery-ui/jquery.ui.position.js"></script>
	<script type="text/javascript" src="../js/jquery-ui/jquery.ui.button.js"></script>
	<script type="text/javascript" src="../js/jquery-ui/jquery.ui.dialog.js"></script>
	<link type="text/css" href="../css/demos.css" rel="stylesheet" />

  <script src="../js/joyWindow.js"  type="text/javascript" language="javascript"></script>
  <script language="javascript">

  function mask()
  {
	  jQ("#dialog-modal").dialog('open');
	  $('a.ui-dialog-titlebar-close').hide();
  }

  function unmask()
  {
	  $('a.ui-dialog-titlebar-close').show();
	  jQ("#dialog-modal").dialog('close');
  }
  
   function handleSuccess(text)
		 {
	   		unmask();
			 try{
			   var jsonObj=eval(text);
			   	 jQ("#dialog-message").html(jsonObj.message);
			   	 jQ("#dialog-message").dialog("open");
			   }catch(e)
			   {
				   jQ("#dialog-message").html(text);
				   jQ("#dialog-message").dialog("open");
			   }
		 }
	 
	function handleFailure(text)
		 {
			 unmask();
			 if(window.confirm("请求出错!  是否查看返回信息?"))
				 jQ("#dialog-message").html(text.responseText);
		   		 jQ("#dialog-message").dialog("open");
			 	
		 }

  var jQCallBack={"success":handleSuccess,"failure":handleFailure}; 

  function doPackFile()
	{
		 var url='packFile.do';
		 var datas=jQ("#form1").serialize();
		 mask();
		 jWindow.ajaxPostJSBack(url,jQCallBack,datas);
	}


	function doPackFileList()
	{
		 var url='packFileList.do';
		 var datas=jQ("#form2").serialize();
		 mask();
		 jWindow.ajaxPostJSBack(url,jQCallBack,datas);
		
	}

	function doFormatListFile(filePath)
	{
		 var url='formatListFile.do';
		 var datas='filePath='+filePath;
		 datas=encodeURI(datas);
		 if(filePath==''||filePath==null)
		 {
			 var dia=jQ("#dialog-message");
			 dia.html("列表目录不能为空!");
			 dia.dialog("open");
			 return;
		 }
		 
		 mask();
		 jWindow.ajaxPostJSBack(url,jQCallBack,datas);
	}
	
	function doDelDir(dir)
	{
		 var url='delDir.do';
		 var datas="packDir="+dir;
		 datas=encodeURI(datas);
		 mask();
		 jWindow.ajaxPostJSBack(url,jQCallBack,datas);
	}

	function doEditFile(filePath)
	{
		 
		 if(filePath==''||filePath==null)
		 {
			 var dia=jQ("#dialog-message");
			 dia.html("列表目录不能为空!");
			 dia.dialog("open");
			 return;
		 }
		 var url='editFile.do';
		 var datas='filePath='+filePath;
		 datas=encodeURI(datas);
		 mask();
		 jWindow.ajaxPostJSBack(url,jQCallBack,datas);
	}
	

	jQ(document).ready(function()
			{
		
			jQ("#tabs").tabs();
			jQ( "#dialog-modal" ).dialog({ autoOpen: false,modal: true,resizable: false,disabled: true });
			jQ("#dialog-message").dialog({autoOpen: false,modal: false, resizable: false});
		 });


	function pickFile(obj)
	{
		var picker=jQ("#file_picker");
		picker.click();
	}

	function setListFile(val)
	{
		jQ("input[name='listFile']").val(val);
	}
	
	window.onload=function()
	{
		var config=new windowConfig();
		config.width=700;
		jWindow.initWindow(config);
		jQ(":button").button();

		doGetConfig();
	}


	var bindKeys=new Array('from2_webInfDir','from2_packDir','from2_listFile','from1_webInfDir','from1_destDir');
	function doSaveConfig()
	{
		 var url='saveBindResource.do';
		 var datas='{';
     
		for(var i=0;i<bindKeys.length;i++)
		{
			keyName=bindKeys[i];
			var value=jQ("#"+keyName).val();
			value=encodeURI(value);
			if(i!=0)
				datas+=',';
	       datas+='"'+keyName+'":'+'"'+value+'"';
		}
		datas+='}';

		datas="bindId=pack_bind&keyMapStr="+datas;
		 mask();
		 jWindow.ajaxPostJSBack(url,jQCallBack,datas);
	}

	


	 function handleSuccess2(text)
		 {
	   		unmask();
			 try{
			   var jsonObj=eval(text);
			   if(jsonObj.state==true)
			   {
				   var keyValues=jsonObj.jsonStr;
				    var keyMap=eval(keyValues);
					for(var i=0;i<bindKeys.length;i++)
					{
						keyName=bindKeys[i];
					   var obj=eval("keyMap."+keyName);
					   if(obj!=null&&obj!=undefined)
					   {
						   jQ("#"+keyName).val(obj);
					   }
				   }
			   }
			   else{
			   	 jQ("#dialog-message").html(jsonObj.message);
			   	 jQ("#dialog-message").dialog("open");
			   }
			   }catch(e)
			   {
				   alert(e);
				   jQ("#dialog-message").html(text);
				   jQ("#dialog-message").dialog("open");
			   }
		 }
	 
	function handleFailure2(text)
		 {
			 unmask();
				 jQ("#dialog-message").html("请求出错!  获取配置信息失败!");
		   		 jQ("#dialog-message").dialog("open");
			 	
		 }

var jQCallBack2={"success":handleSuccess2,"failure":handleFailure2}; 




	function doGetConfig()
	{
		 var url='getBindResource.do';
		 var datas='bindId=pack_bind';

		 jWindow.ajaxPostJSBack(url,jQCallBack2,datas);
	}

	
  </script>
  
  <style type="text/css">
  	html,body {overflow:hidden}
	body{
	background:#F5F5F5;
	}
  </style>
</head>
<body>
<div class="demo">
  <div id="tabs">	
  <ul>
  		<li><a href="#tabs-1">打包文件列表</a></li>
  		<li><a href="#tabs-2">打包单个文件</a></li>
  		<li><a href="#tabs-3">帮助</a></li>
  </ul>
  
	   <div id="tabs-1">
	  <FORM id="form2" METHOD="POST" ACTION="" onsubmit="return false;">
	  <table>
		<tr><td>工程的WEB-INF目录:</td>
		<td><INPUT TYPE="text" NAME="webInfDir" id="from2_webInfDir" value="E:/workspace/ca_cmis_cq/cmis-main/WebContent/WEB-INF/" size="60">
		</td></tr>
		<tr><td>
			打包文件WEB-INF目录:
		</td>
		<td>
		<INPUT TYPE="text" name="packDir" id="from2_packDir" value="E:/pack/WEB-INF/" size="50">
		&nbsp;<input type="button" value="  清空文件夹&nbsp;&nbsp;" onclick="doDelDir(form2.packDir.value);"/>
		</td>
		</tr>
		<tr><td>
			打包列表文件:
		</td>
		<td>
		<INPUT TYPE="text" name="listFile" id="from2_listFile" value="E:/test/pack.txt"  size="50">
		&nbsp;<INPUT TYPE="button" value="浏览" onclick="pickFile(form2.listFile);">
		&nbsp;<INPUT TYPE="button" value="编辑" onclick="doEditFile(form2.listFile.value);">
		</td>
		</tr>
		<tr><td>
			&nbsp;
		</td>
		<td>
		<input type="button" value="规则化列表文件" onclick="doFormatListFile(form2.listFile.value);"/>&nbsp;
		<INPUT TYPE="button" value="打包文件列表" onclick="doPackFileList();">
		<INPUT TYPE="button" value="保存配置信息" onclick="doSaveConfig();">
		</td>
		</tr>
	  </table>
	  </FORM>
	  </div>

  <div id="tabs-2">
  <FORM id="form1" METHOD=POST ACTION="" onsubmit="return false;">
		<table>
		<tr><td>工程的WEB-INF目录:</td>
		<td><INPUT TYPE="text" NAME="webInfDir" id="from1_webInfDir" value="E:/workspace/ca_cmis_cq/cmis-main/WebContent/WEB-INF/" size="60">
		</td></tr>
		<tr><td>
			打包文件WEB-INF目录:
		</td>
		<td>
		<INPUT TYPE="text" name="destDir" id="from1_destDir" value="E:/pack/WEB-INF/" size="50">
		&nbsp;<input type="button" value="清空文件夹" onclick="doDelDir(form1.destDir.value);"/>
		</td>
		</tr>
		<tr><td>
			打包文件相对路径:
		</td>
		<td>
		<INPUT TYPE="text" name="srcFile" value=""  size="60">
		</td>
		</tr>
		<tr><td>
			&nbsp;
		</td>
		<td>
		<INPUT TYPE="button" value="打包单个文件" onclick="doPackFile();">
		</td>
		</tr>
	  </table>
	  </FORM>
	  </div>
	  

	  
	   <div id="tabs-3">
	    <p>
	          可打包单个文件与文件列表,其中文件列表中可以打包文件夹(自动忽略svn信息).<br>
		打包列表文件的规则化文件列表,可以让开发人员只复制文件限定名,由工具进行自动转换!
	    </p>
	   </div>
	</div>  <!-- end of tab -->
	
	
	</div>
	


	<div id="dialog-modal" title="处理中">
	<center><img src="../img/loading2.gif" alt="loading"></img></center>
	</div>
	
	<div id="dialog-message" title="提示信息">
	</div>
	<!--用于选择文件  -->
	<input type="file" style="display:none" name="file_picker" id="file_picker" onchange="setListFile(this.value);"/>
</body>
</html>
